const { PriceDao } = require('../dao/price')

/* ======== Action Logic ============ */
const PriceAction = {
    async getBetween(start, end) {
        console.log('Get From PriceDao.getBetween');
        return new Promise(reslove => PriceDao.getPriceBetween(start, end, rows => reslove(rows)));
    }
}

/* ==== Router Regist  ============ */

const PriceRouter = router => {
    router.get('/action/price/:start/:end', async (ctx, next) => {
        console.log('Router : Get mouse pos by ID :# ', ctx.params.id);
        let row = await PriceAction.getBetween(ctx.params.start,ctx.params.end);
        ctx.set('Content-Type', 'application/json');
        ctx.body = row;
        next();
    });
}
module.exports.PriceRouter = PriceRouter;